﻿#ifndef QLYAVCODEC_H
#define QLYAVCODEC_H
#include <QString>
#include <QVector>
#include <QDebug>

extern "C" {
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
}

class QlyAVCodec
{
public:
    QlyAVCodec();
    QlyAVCodec(const AVCodec *codec);
    ~QlyAVCodec();

    static QVector<QlyAVCodec> allAVCodec();
    QString name() const;
    QString longName() const;
    AVMediaType mediaType() const;
    AVCodecID id() const;
    bool findEncoder(enum AVCodecID id);
    bool findDecoder(enum AVCodecID id);
    bool findEncoder(QString name);
    bool findDecoder(QString name);
    bool isEncoder();
    bool isDecoder();

    bool isSupportedPixelFormat(AVPixelFormat format) const;
    bool isSupportedFrameRate(AVRational rate) const;
    bool isSupportedSampleRate(int rate) const;

    QVector<AVPixelFormat> supportedPixelFormat() const;
    QVector<AVRational> supportedFrameRate() const;
    QVector<int> supportedSampleRate() const;

    const AVCodec	* ptr() {return pCodec;}
private:
    const AVCodec	*pCodec = nullptr;
};

QDebug operator<<(QDebug dbg, QlyAVCodec r);

#endif // QLYAVCODEC_H
